<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑航班 - 航空订票系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/flightbooking/">航空订票系统</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/">首页</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="/flightbooking/flights">航班管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/passengers">旅客管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/tickets">票务管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/flightbooking/dashboard">统计面板</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="/flightbooking/">首页</a></li>
                <li class="breadcrumb-item"><a href="/flightbooking/flights">航班管理</a></li>
                <li class="breadcrumb-item active" aria-current="page">编辑航班</li>
            </ol>
        </nav>

        <div class="card">
            <div class="card-header bg-primary text-white">
                <h5 class="mb-0">编辑航班</h5>
            </div>
            <div class="card-body">
                <form action="/flightbooking/flights/edit" method="post" th:if="${flight != null}">
                    <input type="hidden" name="flightId" th:value="${flight.flightId}">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="flightId">航班号</label>
                                <input type="text" class="form-control" id="flightId" th:value="${flight.flightId}" disabled>
                            </div>
                            <div class="form-group">
                                <label for="airlineCompany">航空公司 <span class="text-danger">*</span></label>
                                <input type="text" class="form-control" id="airlineCompany" name="airlineCompany" th:value="${flight.airlineCompany}" required>
                            </div>
                            <div class="form-group">
                                <label for="departureCity">出发城市 <span class="text-danger">*</span></label>
                                <input type="text" class="form-control" id="departureCity" name="departureCity" th:value="${flight.departureCity}" required>
                            </div>
                            <div class="form-group">
                                <label for="arrivalCity">到达城市 <span class="text-danger">*</span></label>
                                <input type="text" class="form-control" id="arrivalCity" name="arrivalCity" th:value="${flight.arrivalCity}" required>
                            </div>
                            <div class="form-group">
                                <label for="departureTime">出发时间 <span class="text-danger">*</span></label>
                                <input type="datetime-local" class="form-control" id="departureTime" name="departureTime" 
                                       th:value="${#dates.format(flight.departureTime, 'yyyy-MM-dd''T''HH:mm')}" required>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="arrivalTime">到达时间 <span class="text-danger">*</span></label>
                                <input type="datetime-local" class="form-control" id="arrivalTime" name="arrivalTime" 
                                       th:value="${#dates.format(flight.arrivalTime, 'yyyy-MM-dd''T''HH:mm')}" required>
                            </div>
                            <div class="form-group">
                                <label for="basePrice">基本票价 <span class="text-danger">*</span></label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">¥</span>
                                    </div>
                                    <input type="number" class="form-control" id="basePrice" name="basePrice" min="0" step="0.01" 
                                           th:value="${flight.basePrice}" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="capacity">座位容量 <span class="text-danger">*</span></label>
                                <input type="number" class="form-control" id="capacity" name="capacity" min="1" 
                                       th:value="${flight.capacity}" required>
                            </div>
                            <div class="form-group">
                                <label for="remainingSeats">剩余座位数 <span class="text-danger">*</span></label>
                                <input type="number" class="form-control" id="remainingSeats" name="remainingSeats" min="0" 
                                       th:value="${flight.remainingSeats}" required>
                                <small class="form-text text-muted">请注意: 修改剩余座位数可能会影响已有订票</small>
                            </div>
                        </div>
                    </div>
                    <div class="text-right">
                        <a href="/flightbooking/flights" class="btn btn-secondary">取消</a>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </form>
                
                <div class="alert alert-danger" th:if="${flight == null}">
                    未找到航班信息，无法编辑。<a href="/flightbooking/flights" class="alert-link">返回航班列表</a>
                </div>
            </div>
        </div>
    </div>
    
    <footer class="bg-dark text-light mt-5 py-3">
        <div class="container text-center">
            <p class="mb-0">© 2023 航空订票系统 - JZA04</p>
        </div>
    </footer>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 